package thread;

public class Demo07 {
    public static void main(String[] args) {
        Thread t = new Thread(() -> {
            for (int i = 0; i < 5; i++) {
                System.out.println("t1 running");
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
            }
        });
        t.setDaemon(true); // 守护线程 主线程结束了，守护线程也结束 所以就不会打印或只打印一次
        t.start();
    }
}
